package com.entity;

import java.io.Serializable;
import java.util.HashSet;
import java.util.Set;

import javax.persistence.CascadeType;
import javax.persistence.Entity;
import javax.persistence.ForeignKey;
import javax.persistence.GeneratedValue;
import javax.persistence.GenerationType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.JoinTable;
import javax.persistence.ManyToMany;

import org.hibernate.annotations.Cascade;
@Entity
public class Student implements Serializable{

	private int stuId;
	private String name;
	private Set<Course> courses = new HashSet<Course>();
	
	@ManyToMany(cascade=CascadeType.ALL)
	@JoinTable(name="student_course",joinColumns=@JoinColumn(name="stuId"),inverseJoinColumns=@JoinColumn(name="cid")  )
	public Set<Course> getCourses() {
		return courses;
	}
	public void setCourses(Set<Course> courses) {
		this.courses = courses;
	}
	@Id
	@GeneratedValue(strategy=GenerationType.IDENTITY)
	public int getStuId() {
		return stuId;
	}
	public void setStuId(int stuId) {
		this.stuId = stuId;
	}
	public String getName() {
		return name;
	}
	public void setName(String name) {
		this.name = name;
	}
	
}
